/*
 * @Descripttion: 说明
 * @version: V1.0
 * @Author: GaoWei
 * @Date: 2021-06-18 14:25:40
 * @LastEditors: keyi 5284153+zzz_hc@user.noreply.gitee.com
 * @LastEditTime: 2023-03-07 10:05:06
 */
import Vue from "vue";
import App from "./App.vue";
import router from "./router/index";
import store from "./store";
import Global from "@/api/common/Global";

// import "nly-adminlte-vue/dist/adminlte/css/adminlte.css";
// import "nly-adminlte-vue/dist/adminlte/fontawesome-free/css/all.css";
// import "nly-adminlte-vue/dist/adminlte/icon/iconfont.css";

import "nly-adminlte-vue/dist/nly-adminlte-vue.css";
import { NlyAdminlteVue } from "nly-adminlte-vue";
//拖拽插件
import VueDraggableResizable from 'vue-draggable-resizable';
Vue.component('vue-draggable-resizable', VueDraggableResizable);

//Meta
import MetaInfo from 'vue-meta-info'
Vue.use(MetaInfo)
//预编译

//JS工具 lodash
Vue.prototype._ = _;
Vue.prototype.$Global = Global;

import "./core/use";
import "./permission"; // permission control
// import './utils/tool/filter';  //时间格式化

Vue.use(NlyAdminlteVue);

Vue.config.productionTip = false;
//调试
Vue.config.devtools = true;

//弹窗拖动组件
import DragModal from '@/components/DragModal'
Vue.component('DragModal', DragModal);

//dom拖动组件
// import VueDND from 'awe-dnd'
// Vue.use(VueDND);
//dom拖动组件
import VueDndZone from 'vue-dnd-zone'
import 'vue-dnd-zone/vue-dnd-zone.css'
Vue.use(VueDndZone);

//加载更多数据的指令
import loadMore from '@/directive/loadMore'
Vue.use(loadMore)

//动画
import "animate.css"

//数字截取保留小数
Vue.prototype.$numberFormat = function (value) {
    if (!value) return '';
    var intPart = Number(value) - Number(value) % 1; //获取整数部分（这里是windy93的方法）
    var intPartFormat = intPart.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,'); //将整数部分逢三一断

    var floatPart = ".0000"; //预定义小数部分
    var value2Array = value.toString().split(".");

    //=2表示数据有小数位
    if (value2Array.length == 2) {
        floatPart = value2Array[1].toString(); //拿到小数部分

        if (floatPart.length == 1) { //补0,实际上用不着
            return intPartFormat + "." + floatPart + '0';
        } else {
            return intPartFormat + "." + floatPart;
        }

    } else {
        return intPartFormat + floatPart;
    }
}

//调用浏览器打印
import Print from 'vue-print-nb'
Vue.use(Print);

//条形码打印
import VueBarcode from 'vue-barcode';
Vue.component('barcode', VueBarcode);

//处理表格数据过多 编辑时候造成卡屯
import UmyUi from 'umy-ui';
import 'umy-ui/lib/theme-chalk/index.css';
Vue.use(UmyUi);

//  千分位分割
Vue.filter('NumFormat', function (value) {
    if (!value || value == 0 || value == '0' || value == '0.00') return '0.00';
    try {
        value = Number(value);
    } catch (error) {
        return '0.00';
    }
    let valueArr = value.toString().split(".");
    if (valueArr.length < 2 || valueArr[1].length < 2) {
        value = Number(value).toFixed(2);
    }
    let res = value.toString().replace(/\d+/, function (n) { // 先提取整数部分
        return n.replace(/(\d)(?=(\d{3})+$)/g, function ($1) {
            return $1 + ",";
        });
    })
    return res;


    if (!value) return '0.00';
    var intPart = Number(value) - Number(value) % 1; //获取整数部分（这里是windy93的方法）
    var intPartFormat = intPart.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,'); //将整数部分逢三一断

    var floatPart = ".00"; //预定义小数部分
    var value2Array = value.toString().split(".");

    //=2表示数据有小数位
    if (value2Array.length == 2) {
        floatPart = value2Array[1].toString(); //拿到小数部分

        if (floatPart.length == 1) { //补0,实际上用不着
            return intPartFormat + "." + floatPart + '0';
        } else {
            return intPartFormat + "." + floatPart;
        }

    } else {
        return intPartFormat + floatPart;
    }
})

new Vue({
    router,
    store,
    render: h => h(App),
    // mounted () {
    //   document.dispatchEvent(new Event('render-event'))
    // }
}).$mount("#app");
